/*
 * 作者：姚俊
 * 功能：获奖主页面显示的action
 * 日期：2015-05-22
 */
package admin.action.fruits;
import java.util.*;

import admin.service.fruits.AwardService;

import com.opensymphony.xwork2.ActionContext;

import teacher.bean.Award;
import teacher.service.award;

public class AwardAction {
	
	private List<Award> awards;
	//当前页
	private int currentPage;
	//最后一页
	private int endPage;
	private int counts;
	private int flag;
	

	public List<Award> getAwards() {
		return awards;
	}

	public void setAwards(List<Award> awards) {
		this.awards = awards;
	}
	
	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}
	
	public int getEndPage() {
		return endPage;
	}

	public void setEndPage(int endPage) {
		this.endPage = endPage;
	}
	
	public int getCounts() {
		return counts;
	}

	public void setCounts(int counts) {
		this.counts = counts;
	}
	
	public int getFlag() {
		return flag;
	}

	public void setFlag(int flag) {
		this.flag = flag;
	}

	public String execute()
	{
		//当前页为零的时候，把当前页变成1
		if(this.getCurrentPage()==0)
			this.setCurrentPage(1);
		
		int add=0;
		//最后一页
		if(new award().getCountAward()%Constant.pageSize!=0)
		{
			add=1;
		}

		this.setEndPage(new award().getCountAward()/Constant.pageSize+add);
		this.setCounts(new award().getCountAward());
		ActionContext.getContext().put("flag",0);
		this.setFlag(0);
		
		this.setAwards(new AwardService().getSegregateAwardByAll(
				(this.getCurrentPage()-1)*Constant.pageSize+1,Constant.pageSize));
		return "succ";
	}

}
